//
//  ScrollTableViewCell.m
//  BeautyClother
//
//  Created by dllo on 15/9/3.
//  Copyright (c) 2015年 宋爽. All rights reserved.
//

#import "ScrollTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface ScrollTableViewCell ()<UIScrollViewDelegate>

@property (nonatomic, assign) CGFloat offWidth;
@property (nonatomic, assign) CGFloat offHeight;

@end

@implementation ScrollTableViewCell


- (void)dealloc
{
    [super dealloc];
    
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.array = [NSMutableArray array];
        self.offWidth = [[UIScreen mainScreen]bounds].size.width / 375;
        self.offHeight = [[UIScreen mainScreen]bounds].size.height / 667;
        [self createScroll];
        
    }
    return self;
}

- (void)createScroll
{
    self.scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, 250 *_offHeight)];
    
    _scroll.delegate = self;
    [self.contentView addSubview:self.scroll];
    _scroll.contentSize = CGSizeMake(self.array.count * _scroll.frame.size.width, 0);
    _scroll.pagingEnabled = YES;
    _scroll.contentOffset = CGPointMake(self.scroll.frame.size.width, 0);
    _scroll.backgroundColor = [UIColor redColor];
//    [self createImage];
    UILabel *name = [[UILabel alloc]initWithFrame:CGRectMake(20 *_offWidth, 100*_offHeight, 100 *_offWidth ,50 *_offHeight)];
    [self.contentView addSubview:name];
    name.textColor = [UIColor whiteColor];
    name.font = [UIFont boldSystemFontOfSize:30];
    name.text = [self.dic objectForKey:@"cnname"];
    [name release];
    UILabel *engname = [[UILabel alloc]initWithFrame:CGRectMake(20 *_offWidth, 150 *_offHeight, 100 *_offWidth, 50 *_offHeight)];
    [self.contentView addSubview:engname];
    engname.textColor = [UIColor whiteColor];
    engname.text = [self.dic objectForKey:@"enname"];
    [engname release];
    UILabel *language = [[UILabel alloc]initWithFrame:CGRectMake(20 *_offWidth, 200 *_offHeight, 300 *_offWidth, 50 *_offHeight)];
    [self.contentView addSubview:language];
    language.textColor = [UIColor whiteColor];
    language.numberOfLines = 2;
    language.font = [UIFont systemFontOfSize:15];
    language.text = [self.dic objectForKey:@"entryCont"];
    [language release];
    [_scroll release];
    
    
}

- (void)createImage
{
    for (int i = 0; i < self.array.count; i++) {
        UIImageView *iamge = [[UIImageView alloc]initWithFrame:CGRectMake(i * self.frame.size.width, 0, self.frame.size.width, self.scroll.frame.size.height)];
        
        [self.scroll addSubview:iamge];
        [iamge sd_setImageWithURL:[NSURL URLWithString:[self.array objectAtIndex:i]] placeholderImage:[UIImage imageNamed:@"zw.jpg"]];
        
        [iamge release];
    }
    
}


- (void)awakeFromNib {
    
    
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
